package com.huishao.api.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huishao.api.mapper.TagMapper;
import com.huishao.api.entity.Tag;
import com.huishao.api.service.TagService;
import org.springframework.stereotype.Service;
import com.huishao.api.common.PageResult;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huishao.api.utils.MybatisPlusUtil;

/**
 * (Tag)表服务实现类
 *
 * @author huishao
 * @since 2022-12-29 15:29:26
 */
@Service("tagService")
public class TagServiceImpl extends ServiceImpl<TagMapper, Tag> implements TagService {

    @Override
    public PageResult getPage(Integer currentPage, Integer size, Tag tag) {
        Page<Tag> page = new Page<>(currentPage, size);

        QueryWrapper<Tag> queryWrapper = MybatisPlusUtil.queryWrapperBuilder(tag);

        this.page(page, queryWrapper);

        return new PageResult((int) page.getTotal(), page.getRecords());
    }
}

